package com.xzbd.test.simple;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class PictureLabelExample {

	public static void main(String[] args) {

		Image image = new Image(null, 20, 20);
		
		Color red = new Color(null, 255, 0, 0);
		GC gc = new GC(image);
		gc.setBackground(red);
		gc.fillRectangle(image.getBounds());
		gc.dispose();
		red.dispose();

		Shell shell = new Shell();
		PictureLabel label = new PictureLabel(shell, 0);
		label.setImage(image);
		label.setText("Hi Simple Picture Label!");
		Point size = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
		label.setSize(size);
		shell.open();

		Display display = shell.getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();

		}

		image.dispose();

	}

}
